Skip to content

chore: refuse commits and pushes whose identity matches the private denylist - #615

Merged
dmealing merged 3 commits into
mainfrom
fm/mo-identity-leak-guard
Nov 20, 2026
Merged

dmealing merged 3 commits into
mainfrom
fm/mo-identity-leak-guard

Conversation

@dmealing

@dmealing dmealing commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Adds .githooks/identity-scan.sh, which matches commit author and committer name and email against the private denylist. It uses the same denylist source and the same allowed-address stripping as the content scan. staged mode checks the identity git would record for a new commit. range mode prints only the SHAs of matching commits.
  • .githooks/pre-commit runs the staged check, and .githooks/pre-push runs the range check on each pushed ref before the TypeScript gate. The identity check ignores SKIP_TS_TYPECHECK, and --no-verify still skips it. Pre-push reads the pushed refs once and reuses them for the TypeScript gate.
  • .githooks/leak-patterns.sh is also sourced by identity-scan.sh. CONTRIBUTING.md and .githooks/deny-list.example document the guard and note that hosted CI cannot see the private denylist. scripts/leak-scan.test.ts adds tests for the staged, range, and pre-push paths.
Validation

Risk Assessment

✅ Low: Local-hook-only change that meets the intent: pre-commit blocks a denylisted author/committer identity and pre-push scans each outgoing range. Round-1 fixes check out: an unresolvable range now blocks, the case-insensitive sed flag is gone, and pre-push has behavioural tests with fixture repos.

Testing

Drove the identity guard live through real git. Commit-time refusals (author, committer) and push-time refusals (new branch, update, SKIP_TS_TYPECHECK does not bypass) all blocked as intended, and clean identities passed. The fail-closed unresolvable-range case and the denylisted-name-beside-allowed-address case also blocked. The focused leak-scan test file passed (15/15). Baseline broad regression came from the configured test command scripts/ci-local.sh --affected --strict-toolchains, which passed at this target commit and was not re-run. Overall result: pass, with no findings.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Commit with denylisted author email is refused by pre-commit (real git commit, synthetic denylist, disposable repo) and the message names only the role ✅ pass live s1-commit-guard.txt (S1a): 'commit blocked — the author identity git would record matches the private denylist', exit=1
Commit with denylisted committer name only (author clean) is refused ✅ pass live s1-commit-guard.txt (S1b): 'commit blocked — the committer identity ...', exit=1
Commit with clean identity succeeds, and a denylisted name beside the allowed maintainer address is still refused ✅ pass live s3-adversarial-identity.txt: S3a exit=1 (ACMECORP with doug@dougmealing.com blocked); S3b and S3c exit=0
Push of a NEW branch carrying a denylisted-author commit is refused by pre-push; remote unchanged ✅ pass live s2-push-guard.txt (S2a): 'push blocked — author or committer identity matches the private denylist on: <sha>', exit=1; S2f ls-remote shows feat-tainted absent
Clean new-branch push passes the identity guard, and an UPDATE adding a denylisted committer is refused ✅ pass live s2-push-guard.txt: S2b 'new branch feat-clean -> feat-clean', exit=0; S2c 'push blocked', exit=1; ls-remote shows feat-clean at the pre-tainted tip
SKIP_TS_TYPECHECK=1 does not bypass the identity guard (adversarial) ✅ pass live s2-push-guard.txt (S2d): 'push blocked', exit=1
Push naming a remote sha absent locally blocks instead of passing (fail-closed, adversarial) ✅ pass live s2-push-guard.txt (S2e): 'push blocked — cannot list the commits to scan (unresolvable range)', exit=1
Evidence: Commit-time identity guard transcript (real git commit, pre-commit hook)
--- S1a: denylisted AUTHOR email, git commit
  commit blocked — the author identity git would record matches the private denylist (metaobjects is PUBLIC).
  Set a public identity for this repo (git config user.name / user.email).
exit=1
--- S1b: denylisted COMMITTER name only, author clean
  commit blocked — the committer identity git would record matches the private denylist (metaobjects is PUBLIC).
  Set a public identity for this repo (git config user.name / user.email).
exit=1
--- S1c: denylisted AUTHOR and text in the commit message only (identity clean)
exit=0
--- S1d: clean identity
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	.githooks/

nothing added to commit but untracked files present (use "git add" to track)
exit=1
--- history (name/email for each commit)
5df6ae3 author=<Clean> <clean@example.com> committer=<Clean> <clean@example.com>
d4c3aa0 author=<Clean> <clean@example.com> committer=<Clean> <clean@example.com>
Evidence: Push-time identity guard transcript (real git push, pre-push hook, fail-closed case)
--- S2a: NEW branch carrying a commit with denylisted AUTHOR (commit made with hooks bypassed)

  push blocked — author or committer identity matches the private denylist on:
      0be28c293e9486826adc2d23d1a3ace1cf42d567
  Rewrite those commits with a public identity (metaobjects is PUBLIC).
error: failed to push some refs to '/mnt/scratch/idg/remote.git'
exit=1
--- S2b: NEW clean branch, clean identity (TS gate skipped; identity guard must pass)
pre-push: SKIP_TS_TYPECHECK=1 set — skipping the TS typecheck gate (you asked for it).
To /mnt/scratch/idg/remote.git
 * [new branch]      feat-clean -> feat-clean
exit=0
--- S2c: UPDATE of remote branch feat-clean, tainted COMMITTER added on top

  push blocked — author or committer identity matches the private denylist on:
      197b3ac103af8406daf63e9e8d4464a977cfd63f
  Rewrite those commits with a public identity (metaobjects is PUBLIC).
error: failed to push some refs to '/mnt/scratch/idg/remote.git'
exit=1
--- S2d: tainted branch again with SKIP_TS_TYPECHECK=1 (must still block; skip only covers TS gate)

  push blocked — author or committer identity matches the private denylist on:
      0be28c293e9486826adc2d23d1a3ace1cf42d567
  Rewrite those commits with a public identity (metaobjects is PUBLIC).
error: failed to push some refs to '/mnt/scratch/idg/remote.git'
exit=1
--- S2e (adversarial, fail closed): pre-push stdin names a remote sha not present locally

  push blocked — cannot list the commits to scan (unresolvable range); fetch the remote and retry:
      fatal: Invalid revision range 1111111111111111111111111111111111111111..197b3ac103af8406daf63e9e8d4464a977cfd63f
exit=1
--- S2f: remote state after attempts (feat-tainted must be absent; feat-clean at the tainted-free tip only if pushed)
d4c3aa014025d80c67d69cd52de8b2c20783d77c	HEAD
31c32f0358ab932a6af43e236c4afcf0a1aec75f	refs/heads/feat-clean
d4c3aa014025d80c67d69cd52de8b2c20783d77c	refs/heads/main
Evidence: Adversarial identity transcript (name beside allowed address, clean commits)
--- S3a: denylisted name sitting BESIDE the allowed address (author name acmecorp, email doug@dougmealing.com)
  commit blocked — the author identity git would record matches the private denylist (metaobjects is PUBLIC).
  Set a public identity for this repo (git config user.name / user.email).
exit=1
--- S3b: allowed address alone, clean name (must pass)
exit=0
--- S3c: clean identity with a staged change (must pass)
exit=0
a10cc9f author=<Clean> <clean@example.com> committer=<Clean> <clean@example.com>
7ab643e author=<Clean> <doug@dougmealing.com> committer=<Clean> <clean@example.com>
5df6ae3 author=<Clean> <clean@example.com> committer=<Clean> <clean@example.com>
Evidence: Focused test run: scripts/leak-scan.test.ts (15 pass)
bun test v1.3.14 (0d9b296a)

 15 pass
 0 fail
 32 expect() calls
Ran 15 tests across 1 file. [487.00ms]

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 3 issues found → auto-fixed ✅
  • ⚠️ .githooks/identity-scan.sh:49 - The pre-push identity guard fails open. git log ... 2&gt;/dev/null swallows every error, and the loop at identity-scan.sh:49 then sees no commits and the script exits 0. Failing sequence: a force-push where the remote sha is not present locally. range &#34;$remotesha..$localsha&#34; errors on the unknown object, nothing is printed, and tainted commits push. A bad range also passes silently. The guard exists to stop exactly the leaked-identity push, so an unresolvable range should block, or at least warn. Fix: check the git log exit status (for example git rev-list first) and return 1 with a message when it fails. The --not --remotes branch at pre-push:36 has the same silent-pass behaviour if git log errors.
  • ⚠️ .githooks/identity-scan.sh:28 - sed -E &#34;s/$LEAK_ALLOW//Ig&#34; uses the I flag on s///. GNU sed accepts it. BSD/macOS sed rejects it with "bad flag in substitute command". The repo explicitly supports macOS (/Users/ pattern). On such a machine sed prints nothing, grep -q finds no match, matches returns 1 for every identity, and both hooks pass silently. Use a portable approach, for example grep -oiE or awk with tolower, or drop the vestigial allow-strip. LEAK_ALLOW itself is described as vestigial in leak-patterns.sh. Stripping it also lets a denylisted name pass when it sits beside the allowed address in the same identity.
  • ⚠️ scripts/leak-scan.test.ts:90 - The pre-push wiring has no behavioural test. Its stdin parsing, the new-branch --not --remotes path, the remotesha..localsha path and the exit-before-TS-gate ordering are untested. The pre-push edit is also where done &lt;&lt;&lt; &#34;$_PUSH_REFS&#34; changed how the existing TS gate reads its input, which is a regression risk. The new tests invoke identity-scan.sh range directly and never run .githooks/pre-push with ref lines on stdin. Add a test that feeds ref lines to pre-push in a fixture repo with a tainted commit. Cover a new branch (zero remote sha) and an update, and assert exit 1. A plausible wrong behaviour it would reject: the guard being skipped for new branches, or an argument-order bug in the range call.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Commit with denylisted author email is refused by pre-commit (real git commit, synthetic denylist, disposable repo) and the message names only the role ✅ pass live s1-commit-guard.txt (S1a): 'commit blocked — the author identity git would record matches the private denylist', exit=1
Commit with denylisted committer name only (author clean) is refused ✅ pass live s1-commit-guard.txt (S1b): 'commit blocked — the committer identity ...', exit=1
Commit with clean identity succeeds, and a denylisted name beside the allowed maintainer address is still refused ✅ pass live s3-adversarial-identity.txt: S3a exit=1 (ACMECORP with doug@dougmealing.com blocked); S3b and S3c exit=0
Push of a NEW branch carrying a denylisted-author commit is refused by pre-push; remote unchanged ✅ pass live s2-push-guard.txt (S2a): 'push blocked — author or committer identity matches the private denylist on: <sha>', exit=1; S2f ls-remote shows feat-tainted absent
Clean new-branch push passes the identity guard, and an UPDATE adding a denylisted committer is refused ✅ pass live s2-push-guard.txt: S2b 'new branch feat-clean -> feat-clean', exit=0; S2c 'push blocked', exit=1; ls-remote shows feat-clean at the pre-tainted tip
SKIP_TS_TYPECHECK=1 does not bypass the identity guard (adversarial) ✅ pass live s2-push-guard.txt (S2d): 'push blocked', exit=1
Push naming a remote sha absent locally blocks instead of passing (fail-closed, adversarial) ✅ pass live s2-push-guard.txt (S2e): 'push blocked — cannot list the commits to scan (unresolvable range)', exit=1
  • scripts/ci-local.sh --affected --strict-toolchains
  • Baseline (already ran, not re-run): scripts/ci-local.sh --affected --strict-toolchains passed at 14d628fea. No source or test files changed in this turn, so no re-run.
  • Scenario 1 (commit guard): disposable repo at a scratch path, hooks copied to .githooks/ with core.hooksPath set, synthetic hooks.denyListPath containing acmecorp and acme-abbr. Ran real git commit with denylisted author email, denylisted committer name only, and clean identity.
  • Scenario 2 (push guard): same fixture with a local bare remote. Ran real git push of a new branch carrying a denylisted-author commit (blocked, remote unchanged), a new clean branch (passes with SKIP_TS_TYPECHECK=1), an update adding a denylisted committer (blocked), and the tainted branch again with SKIP_TS_TYPECHECK=1 (still blocked).
  • Scenario 2e (adversarial, fail closed): fed .githooks/pre-push a ref line whose remote sha is absent locally; expected and observed exit 1 with 'cannot list the commits'.
  • Scenario 3 (adversarial): denylisted name ACMECORP beside allowed address doug@dougmealing.com in the same author identity, committed with real git commit; blocked. Allowed address with a clean name, and clean identity, both committed.
  • bun test scripts/leak-scan.test.ts from the worktree root: 15 pass, 0 fail (identity scan, range, and pre-push wiring tests).
  • Evidence transcripts: s1-commit-guard.txt, s2-push-guard.txt, s3-adversarial-identity.txt, leak-scan-test.txt. Disposable fixture removed afterwards; worktree left clean; no background jobs started.
  • Scope note, not a finding: a commit message that mentions the denylisted name with a clean identity still commits (exit 0). The intent covers only author and committer identity, so this is correct.
⏭️ **Document** - skipped
  • ℹ️ AGENTS.md:98 - AGENTS.md (agent memory, human-owned) describes the pre-commit hygiene hook but not the new author/committer identity check, and the pre-push bypass note does not say the identity guard survives SKIP_TS_TYPECHECK. Not factually wrong, so left unchanged per the AGENTS.md edit rule. Human decision whether to add one line.
  • ℹ️ docs/RELEASING.md:992 - Public-repo hygiene prose is duplicated across AGENTS.md, CONTRIBUTING.md and docs/RELEASING.md, and each copy now describes the hooks differently. Out-of-scope follow-up: keep the hook behaviour in CONTRIBUTING.md (contribution-mechanics owner) and reduce the other two to pointers.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@dmealing
dmealing merged commit b78da0f into main Nov 20, 2026
17 of 19 checks passed
@dmealing
dmealing deleted the fm/mo-identity-leak-guard branch November 20, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant